package util.datastructure;

import util.LogUtils;

public class TreeNode {
	public int val;
	public TreeNode left;
	public TreeNode right;

	public TreeNode() {
	
	}
	public TreeNode(int x) {
		val = x;
	}
	public TreeNode(int x, TreeNode left, TreeNode right) {
		this.val = x;
		this.left  = left;
		this.right = right;
	}
	@Override
	public String toString() {
		return "TreeNode [val=" + val + ", left=" + left + ", right=" + right
				+ "]";
	}
	
	/**
	 * new实例
	 */
	
	/**
	 * 中序遍历
	 * @param root
	 */
	public void traverse(String tag, TreeNode root) {
		LogUtils.println(tag);
		traverse(root);
		LogUtils.br();
	}
	public void traverse(TreeNode root) {
		if (root == null)	return;
		traverse(root.left);
		LogUtils.print(root.val);
		traverse(root.right);
	}
}
